<?php
require_once '../sub/init.php';
header("Cache-control: private");
require_once 'chkUadm.php';
if(!in_array('u_bbs',$QXARR))exit(noauth());
switch ($submitok) {
	case"alldel":
		$tmeplist = $list;
		if(empty($tmeplist))json_exit(array('flag'=>0,'msg'=>'请选择您要删除的信息'));
		if(!is_array($tmeplist))exit(JSON_ERROR);
		if(count($tmeplist)>=1){
			foreach($tmeplist as $v){$v=intval($v);
				$row2 = $db->ROW(__TBL_USER_BBS__,"uid,senduid,addtime","id=".$v,'num');$uid_= $row2[0];$senduid_= $row2[1];$addtime_= $row2[2];
				$row2 = $db->ROW(__TBL_USER__,"nickname","id=".$uid_,'num');$nickname= $row2[0];
				$row2 = $db->ROW(__TBL_USER__,"nickname","id=".$senduid_,'num');$sendnickname= $row2[0];
				$uid=$senduid;
				AddLog('批量删除【'.$sendnickname.'（uid:'.$senduid.'）】->【'.$nickname.'（uid:'.$uid_.'）】评价记录，评价时间->'.YmdHis($addtime_));
				$db->query("DELETE FROM ".__TBL_USER_BBS__." WHERE id=".$v);
			}
		}
		json_exit(array('flag'=>1,'msg'=>'操作成功'));
	break;
	case"modflag":
		if (!ifint($classid))callmsg("forbidden","-1");
		$rt = $db->query("SELECT flag FROM ".__TBL_USER_BBS__." WHERE id=".$classid);
		if($db->num_rows($rt)){
			$rows = $db->fetch_array($rt,'name');
			$flag = $rows['flag'];
			switch($flag){
				case"-1":$SQL="flag=1";break;
				case"0":$SQL="flag=1";break;
				case"1":$SQL="flag=-1";break;
			}
			$db->query("UPDATE ".__TBL_USER_BBS__." SET ".$SQL." WHERE id=".$classid);
			AddLog('【评价此人】评价状态修改->评价id:'.$id);
			header("Location: ".SELF."?p=$p&kind=$kind");
		}else{
			callmsg("您要操作的信息不存在或已经删除！","-1");
		}
	break;
	case"dataflag1":
		if(empty($list))json_exit(array('flag'=>0,'msg'=>'请选择您要审核的信息'));
		if(!is_array($list))exit(JSON_ERROR);
		if(count($list)>=1){
			foreach($list as $id){
				$id=intval($id);
				$db->query("UPDATE ".__TBL_USER_BBS__." SET flag=1 WHERE id=".$id);
				AddLog('【评价此人】评论审核通过->评价id:'.$id);
			}
		}
		json_exit(array('flag'=>1,'msg'=>'操作成功'));
	break;
	case"mod_update":
		if (!ifint($id))alert_adm("id参数错误","-1");
		$content = dataIO($content,'in',10000);
		$db->query("UPDATE ".__TBL_USER_BBS__." SET content='$content' WHERE id=".$id);
		AddLog('【评价此人】->修改评价内容：'.trimhtml($content));
		alert_adm_parent("修改成功","u_bbs.php?p=$p&kind=$kind");
	break;
	case"mod":
		if (!ifint($id))alert("id参数错误","-1");
		$rt = $db->query("SELECT content FROM ".__TBL_USER_BBS__." WHERE id=".$id);
		if($db->num_rows($rt)){
			$row     = $db->fetch_array($rt,'name');
			$content = dataIO($row['content'],'out');
		}else{
			alert_adm("该评论不存在！","-1");
		}
	break;
}
if($session_kind == 'crm')$SQLGJ = " AND b.admid=".$session_uid;//认领红娘名下
$SQL = "";
$Skeyword = trimm($Skeyword);
if (ifint($Skeyword)){
	$SQL = " AND (b.id=$Skeyword) ";
}elseif(!empty($Skeyword)){
	$SQL = " AND ( ( b.uname LIKE '%".$Skeyword."%' ) OR ( b.nickname LIKE '%".$Skeyword."%' ) OR ( b.nickname LIKE '%".urlencode($Skeyword)."%' ) )";
}
if(ifint($Skeyword2)){
	$SQL = " AND (a.uid=$Skeyword2) ";
}
$Skey3 = trimm($Skey3);
if (!empty($Skey3)){
	$SQL = " AND a.content LIKE '%".dataIO($Skey3,'in')."%' ";
}
if (ifint($uid)){
	$SQL = " AND (a.senduid=$uid) ";
	$_ADM['admPageSize']=8;
}
switch ($kind) {
	case 'f0':$SQL .= " AND a.flag=0";break;
	case 'f1':$SQL .= " AND a.flag=1";break;
	case 'f_1':$SQL .= " AND a.flag=-1";break;
}
$SORT = " ORDER BY a.id DESC ";
$rt = $db->query("SELECT a.*,b.sex,b.grade,b.nickname FROM ".__TBL_USER_BBS__." a,".__TBL_USER__." b WHERE a.senduid=b.id ".$SQL.$SQLGJ.$SORT." LIMIT ".$_ADM['admLimit']);
$total = $db->num_rows($rt);?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="<?php echo HOST;?>/res/www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<link href="css/main.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css">
</head>
<style>
.box{min-width:1150px;padding:0}
</style>
<body<?php echo (ifint($uid) || $submitok=='mod')?' class="body"':'';?>>
<?php if($submitok=='mod'){?>
    <form name="ZEAI_FORM" method="POST" action="<?php echo SELF;?>">
    <table class="table Mtop30 W500">
    <tr>
      <td class="tdL">评论内容</td>
      <td class="tdR"><textarea name="content" rows="7" class="textarea W100_" id="content"><?php echo $content;?></textarea></td>
    </tr>
    <tr>
      <td colspan="2" align="center"><input class="btn size3" type="submit" value="修改并保存" />
        <input name="submitok" type="hidden" value="mod_update" />
        <input name="id" type="hidden" value="<?php echo $id;?>" />
      </td>
    </tr>
    </table>
    </form>
<?php exit;}?>

<div class="box">
	<?php if (!ifint($uid)){?>
        <div class="boxL">
        <?php if(CRMQX('tip_list')){?><a href="tip_list.php?uid=<?php echo $uid;?>">消息通知</a><?php }?>
        <?php if(CRMQX('chat_list')){?><a href="chat_list.php?uid=<?php echo $uid;?>">私信聊天</a><?php }?>
        <?php if(CRMQX('view_list')){?><a href="view_list.php?uid=<?php echo $uid;?>">谁看过我</a><?php }?>
        <?php if(CRMQX('gz_list')){?><a href="gz_list.php?uid=<?php echo $uid;?>">用户关注</a><?php }?>
        <?php if(CRMQX('hh_list')){?><a href="hh_list.php?uid=<?php echo $uid;?>">用户互换</a><?php }?>
        <?php if(CRMQX('u_bbs')){?><a href="u_bbs.php?uid=<?php echo $uid;?>" class='ed'>用户评价</a><?php }?>
        <?php if(CRMQX('u_endtime')){?><a href="u_endtime.php?uid=<?php echo $uid;?>">最新登录</a><?php }?>
        </div>
        <div class="boxR">
            <div class="topsearch">
              <form name="ZEAI_CN__form1" method="get" action="<?php echo SELF; ?>">
                    <input name="Skeyword" type="text" id="Skeyword" maxlength="25" class="input size2 W200" placeholder="按主动方UID/用户名/昵称" value="<?php echo $Skeyword; ?>">
                    <input type="hidden" name="p" value="<?php echo $p;?>" />
                    <input type="hidden" name="kind" value="<?php echo $kind;?>" />
                    <button type="submit" class="btn size2"><i class="ico">&#xe6c4;</i> 搜索</button>
                </form>
              <form name="ZEAI_CN__form2" method="get" action="<?php echo SELF; ?>" style="margin-left:10px">
                    <input name="Skeyword2" type="text" id="Skeyword2" maxlength="10" class="input size2 W100" placeholder="按被动方UID" value="<?php echo $Skeyword2; ?>">
                    <input type="hidden" name="p" value="<?php echo $p;?>" />
                    <input type="hidden" name="kind" value="<?php echo $kind;?>" />
                    <button type="submit" class="btn size2"><i class="ico">&#xe6c4;</i> 搜索</button>
                </form>
              <form name="ZEAI_CN__form3" method="get" action="<?php echo SELF; ?>" style="margin-left:10px">
                    <input name="Skey3" type="text" id="Skey3" maxlength="25" class="input size2 W150" placeholder="按评价内容" value="<?php echo $Skey3; ?>">
                    <input type="hidden" name="p" value="<?php echo $p;?>" />
                    <input type="hidden" name="kind" value="<?php echo $kind;?>" />
                    <button type="submit" class="btn size2"><i class="ico">&#xe6c4;</i> 搜索</button>
                </form>
                <div class="rbox">
                    <a href="u_bbs.php"<?php echo (empty($kind))?" class='ed'":""; ?>>全部<?php echo (empty($kind))?'<b>'.$total.'</b>':''; ?></a>
                    <a href="u_bbs.php?kind=f0" <?php echo ($kind == 'f0')?' class="ed"':''; ?>>未审<?php echo ($kind == 'f0')?'<b>'.$total.'</b>':''; ?></a>
                    <a href="u_bbs.php?kind=f1" <?php echo ($kind == 'f1')?' class="ed"':''; ?>>已审<?php echo ($kind == 'f1')?'<b>'.$total.'</b>':''; ?></a>
                    <a href="u_bbs.php?kind=f_1" <?php echo ($kind == 'f_1')?' class="ed"':''; ?>>隐藏<?php echo ($kind == 'f_1')?'<b>'.$total.'</b>':''; ?></a>
                </div>
                <div class="clear"></div>
            </div>
    <?php }?>
    <!---->
	<?php
    if ($total <= 0 ) {
        echo "<div class='nodataico'><i></i>暂无内容";
        if (!ifint($uid))echo"<br><a class='aQINGed' href='javascript:history.back(-1)'>返回</a>";
        echo "</div>";
    } else {
        $page_skin=2;$pagemode=3;$pagesize=$_ADM['admPageSize'];require_once ZEAI.'sub/page.php';?>
        <form id="www_zeai_cn_FORM" method="get" action="<?php echo SELF; ?>">
        <table class="tablelist">
        <tr>
        <th width="20"><input type="checkbox" id="checkboxall1" class="checkskin checkboxall"><label for="checkboxall1" class="checkskin-label"><i class="i1"></i></label></th>
        <th width="50">ID</th>
        <th width="150" align="left">主动方</th>
        <th width="120" align="center">评价时间</th>
        <th width="21" align="center">&nbsp;</th>
        <th width="150" align="left">被动方</th>
        <th align="left">评价内容/修改</th>
        <th width="11" align="left">&nbsp;</th>
        <th width="60">评价状态</th>
        <th width="22">&nbsp;</th>
        </tr>
        <?php
        for($i=1;$i<=$pagesize;$i++) {
            $rows = $db->fetch_array($rt,'name');
            if(!$rows) break;
            $id = $rows['id'];$uidd = $rows['uid'];
            $senduname = trimhtml($rows['uname']);
            $senduname = str_replace($Skeyword,"<font color=red><b>".$Skeyword."</b></font>",$senduname);
            $sendnickname = trimhtml(dataIO($rows['nickname'],'out'));
            $sendnickname = str_replace($Skeyword,"<font color=red><b>".$Skeyword."</b></font>",$sendnickname);
            $sex   = $rows['sex'];
            $grade = $rows['grade'];
            if(empty($sendnickname))$sendnickname = $uname;
            $flag    = $rows['flag'];
            $senduid = $rows['senduid'];
            $addtime = YmdHis($rows['addtime']);
			$content = dataIO($rows['content'],'out');
			?>
        	<tr id="tr<?php echo $id;?>">
            <td width="20" height="40"><input type="checkbox" name="list[]" value="<?php echo $id; ?>" uid="<?php echo $senduid; ?>" id="id<?php echo $id; ?>" class="checkskin"><label for="id<?php echo $id; ?>" class="checkskin-label"><i class="i1"></i></label>
            </td>
          <td width="50" class="C999"><label for="id<?php echo $id; ?>"><?php echo $id;?></label></td>
          <td width="150" align="left"><a href="<?php echo Href('crm_u',$senduid);?>">
            <?php
            echo uicon($sex.$grade);
            echo '<span class="middle">';
            echo $sendnickname."<br><font class='S12 C999'>uid：".$senduid."</font>";
            echo '</span>';?>
            </a></td>
          <td width="120" align="center" class="lineH200 C666 padding10">
                <h5><?php echo $addtime;?></h5>
                <i class="ico S24 Cccc">&#xe62d;</i>
      		</td>
          <td width="21" align="center" class="lineH200 C666 padding10">&nbsp;</td>
            <td width="150" align="left">
                <?php 
                $row2 = $db->ROW(__TBL_USER__,"sex,grade,nickname","id=".$uidd);
                if (!$row2){
                    echo '无';
                }else{
                    $sex2      = $row2[0];
                    $grade2    = $row2[1];
                    $nickname2 = dataIO($row2[2],'out');
                }?><a href="<?php echo Href('crm_u',$uidd);?>"><?php
                    echo uicon($sex2.$grade2);
                    echo '<span class="middle">';
                    echo $nickname2."<br><font class='S12 C999'>uid：".$uidd."</font>";
                    echo '</span>';
                    ?>
                </a>
            </td>
            <td align="left"><?php echo str_replace($Skey3,"<font color=red><b>".$Skey3."</b></font>",$content); ?> <a class="editico tips" tips-title='修改' tips-direction='left' clsid="<?php echo $id; ?>" nickname="<?php echo urlencode($sendnickname);?>"></a></td>
            <td width="11" align="left">&nbsp;</td>
            <td width="60">
                <?php
                $fHREF = SELF."?submitok=modflag&classid=$id&kind=$kind&p=$p&uid=$uid";
                if($flag==-1){?><a href="<?php echo $fHREF;?>" class="aLAN" title="点击显示">隐藏</a><?php }?>
                <?php if($flag==0){?><div class="C999" style="margin-bottom:6px">点击审核</div><a href="<?php echo $fHREF;?>" class="aHUANG" title="点击审核">未审</a><?php }?>
                <?php if($flag==1){?><a href="<?php echo $fHREF;?>" class="aLV" title="点击隐藏">正常</a><?php }?>
            </td>
            <td width="22">&nbsp;</td>
          </tr>
        <?php } ?>
    </table>
    <input type="hidden" name="submitok" id="submitok" value="" />
    </form>
    <?php }?>
    <!---->
	<?php if (!ifint($uid)){?></div><?php }?>
    <div class="clear"></div>
</div>
<?php if ($total > 0 ){?>
<div class="listbottombox">
	<input type="checkbox" id="checkboxall2" class="checkskin checkboxall"><label for="checkboxall2" class="checkskin-label"><i class="i1"></i></label>　
    <button type="button" id="btnflaglist" class="btn size2 LV disabled action">批量审核</button>　
    <button type="button" id="btndellist" class="btn size2 HEI2 disabled action">批量删除</button>　
    <button type="button" id="btnsend" value="" class="btn size2 disabled action" onClick="sendTipFn2(this);"><i class="ico">&#xe676;</i> 发送消息</button>
	<?php if ($total > $pagesize)echo '<div class="pagebox FR">'.$pagelist.'</div>'; ?>
</div>
<script>
var bg = '<?php echo $_Style['list_bg']; ?>',overbg = '<?php echo $_Style['list_overbg']; ?>',selectbg = '<?php echo $_Style['list_selectbg']; ?>';
o('btndellist').onclick = function() {
	allList({
		btnobj:this,
		url:'u_bbs'+zeai.ajxext+'submitok=alldel',
		title:'批量删除',
		msg:'正在删除中...',
		ifjson:true,
		ifconfirm:true
	});	
}
if(!zeai.empty(o('btnflaglist')))o('btnflaglist').onclick = function() {
	allList({
		btnobj:this,
		url:'u_bbs'+zeai.ajxext+'submitok=dataflag1',
		title:'批量审核',
		content:'',
		msg:'审核处理中...',
		ifjson:true,
		ifconfirm:true
	});	
}
zeai.listEach('.editico',function(obj){
	obj.onclick = function(){
		var id = parseInt(obj.getAttribute("clsid")),nickname=obj.getAttribute("nickname");
		zeai.iframe('修改【'+decodeURIComponent(nickname)+'】评论内容','u_bbs.php?submitok=mod&id='+id,600,300);
	}
});
</script>
<script src="js/zeai_tablelist.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<?php }?>
<?php require_once 'bottomadm.php';?>